use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::MomentumIndex

///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct MTI {
    ///  1 signal
    /// When both momentums are positive, returns full buy signal.
    /// When both momentums are negative, returns full sell signal.
    /// Otherwise returns no signal.
    ///
    pub signal0: Option<IndicatorActionWrap>,

    ///2 values
    ///slow momentum value
    ///Range in (-inf; +inf)
    pub slow: ValueType,
    ///
    ///fast momentum value
    ///Range in (-inf; +inf)
    pub fast: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct MTIConfig {
    ///period1: PeriodType
    ///Slow momentum period. Default is 10.
    ///
    ///Range in (period2; PeriodType::MAX)
    ///
    pub period1: PeriodType,

    ///period2: PeriodType
    ///Fast momentum period. Default is 1.
    ///
    ///Range in [1; period1)
    ///
    pub period2: PeriodType,
    //§source: Source
    // Source value type. Default is Close
    // pub source: Source,
}

impl Default for MTIConfig {
    fn default() -> Self {
        Self {
            period1: 10,
            period2: 1,
            // source: Source::Close,
        }
    }
}
